#!/usr/bin/python3
# coding: utf-8

from flask import Flask
from flask_moment import Moment
from flask_admin import Admin
import click

app = Flask(__name__)
app.config.from_object('config')
moment = Moment(app)

from app.models import db, Post, Category
from app.views import PostAdminView, CategoryAdminView

admin = Admin(app, name='博客后台管理', base_template='my_master.html')
db.init_app(app)

@app.cli.command()
def initdb():
	'Usage: >flask initdb'
	db.drop_all()
	db.create_all()
	click.echo('Init the db')

admin.add_view(PostAdminView(Post, db.session))
admin.add_view(CategoryAdminView(Category, db.session))

